#encoding:utf-8
#將trainingData和Labels結合起來成為一個檔案
#-bhchen
import sys

if len(sys.argv) <= 3:
    print('Usage: python {0} LongInputFile EliminateOutputFile '.format(sys.argv[0]))
    raise SystemExit

print('Merge ' + sys.argv[1] + ' and '+ sys.argv[2] + ' to ' + sys.argv[3])
inData = open(sys.argv[1])
inLabels = open(sys.argv[2])

outf = open(sys.argv[3],'w')
lines_data = inData.readlines()
lines_label = inLabels.readlines()
for i in range(25640):
    if i==0:
        outf.write('a_' + str(i+1) )
    else:
        outf.write(',a_' + str(i+1) )
outf.write(',class\n')
for i in range(len(lines_data)):    
    data = lines_data[i].split()
    num_data = len(data)
    #label = lines_label[i].split()
    #num_label = len(label)
    
    start=0
    for x in range(num_data):
        if int(data[x]) > 10:
            if start == 0:
                outf.write('1')
                start=1
            else:
                outf.write(',1')
        else:
            if start == 0:
                outf.write('0')
                start=1
            else:
                outf.write(',0')    
    outf.write(','+lines_label[i])
    #outf.write('\n');        
inData.close();
inLabels.close();
outf.close();